# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=libplist
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.0.0
pkgrel=1
pkgdesc='A library to handle Apple Property List format in binary or XML (mingw-w64)'
arch=('any')
url='http://www.libimobiledevice.org/'
license=('GPL2+')
source=("http://www.libimobiledevice.org/downloads/${_realname}-${pkgver}.tar.bz2"
        001-cython-module.patch)
depends=("${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-cython")
options=('staticlibs')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3")
sha256sums=('3a7e9694c2d9a85174ba1fa92417cfabaea7f6d19631e544948dc7e17e82f602'
            '42e7c4d3fa91b5b5d206faf51e95690f74b751b1896056bb32a616e17563ee93')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-cython-module.patch

  autoreconf -fiv
}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}

  PYTHON=${MINGW_PREFIX}/bin/python3 \
  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --enable-static \
      --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${CARCH}
  # || true because of FAIL: bigarraycmp .. File does not exists
  make check || true
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"

  rm -f ${pkgdir}${MINGW_PREFIX}/lib/python*/site-packages/*.a
}
